import request from "../utils/request";

/**
 * 获取购物车列表
 */

export const getCar = (id: string) =>
  request.get("/cart/list", { params: { id } });

/**
 * 加入购物车
 */

export const addCar = (data: { id: number; goodsId: number }) =>
  request.post("/cart/add", data);

/**
 * 删除单条商品
 */
export const delGoods = (id: string, goodsId: number) =>
  request.get("/cart/remove", { params: { id, goodsId } });

/**
 * 删除所有选中商品
 */
export const delCheck = (id: number) =>
  request.get("/cart/remove/select", { params: { id } });

/**
 * 清空购物车
 */
export const clearCar = (id: number) =>
  request.get("/cart/clear", { params: { id } });

/**
 * 修改商品选中状态
 */
export const carSelect = (data: { id: number; goodsId: number }) =>
  request.post("/cart/select", data);

/**
 * 修改商品全选按钮
 */
export const selectAll = (data: { id: number; type: boolean }) =>
  request.post("/cart/select/all", data);

/**
 * 修改购买数量
 */
export const carNum = (data: { id: number; goodsId: number; number: number }) =>
  request.post("/cart/number", data);
/**
 * 支付
 */
export const onPay = (data: { id: number}) =>
  request.post("/cart/pay", data);